# coding: utf-8

import json
from flask import Blueprint, render_template
from app.utils import helper

chart = Blueprint('chart', __name__)


# 代码统计可视化
@chart.route('/chart/code_visual/<int:nid>', methods=['GET', 'POST'])
def code_visual(nid):
    visual_data = helper.fetch_all(
        "SELECT line,note_line,blank_line,actual_line,actual_line_rate,note_line_rate,blank_line_rate,file_name FROM record where user_id=%s",
        (nid,))
    ret = json.dumps(visual_data)
    print("ret:", ret)
    return render_template('chart/files_chart.html', ret=ret)
